﻿using System;
using Hjt212Parser;
using System.Linq;
using System.Text;
using Biz.Buffer;
using Biz.EF.Platform;
using log4net;


namespace Biz.Process
{
    /// <summary>
    /// 主要处理各种状态指令
    /// </summary>
    public class UplineStatusInstruction
    {
        private static readonly ILog Log = LogManager.GetLogger(typeof(UplineStatusInstruction));

        public static void Process0000(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);

                var type = CommonInformation.GetDeviceTypeByMn(mn);
                var items = pCtx.RealDataMonitorMains.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                    .Where(t => t.设备信息ID == letport.ID).ToList();
                Log.Info("Offline Time：" + datatime);
                Log.Info("Device Type：" + type);
                Log.Info("Items：" + items.Count);
                foreach (var item in items)
                {
                    switch (type)
                    {
                        case DeviceType.Monitor:
                            item.数采在线状态ID = 802;

                            if (item.数采在离线状态时间 == null || item.数采在离线状态时间.Value < datatime)
                                item.数采在离线状态时间 = datatime;
                            Log.Info("数采在线状态ID:" + item.数采在线状态ID);
                            break;
                        case DeviceType.Total:
                            item.总量在线状态ID = 802;
                            if (item.总量在离线状态时间 == null || item.总量在离线状态时间.Value < datatime)
                                item.总量在离线状态时间 = datatime;
                            break;
                    }
                }
                int successes = pCtx.SaveChanges();
                Log.Info("成功更新记录数：" + successes);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process9999(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);

                var type = CommonInformation.GetDeviceTypeByMn(mn);
                var items = pCtx.RealDataMonitorMains.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                    .Where(t => t.设备信息ID == letport.ID).ToList();
                foreach (var item in items)
                {
                    switch (type)
                    {
                        case DeviceType.Monitor:
                            item.数采在线状态ID = 801;
                            if (item.数采在离线状态时间 == null || item.数采在离线状态时间.Value < datatime)
                                item.数采在离线状态时间 = datatime;
                            break;
                        case DeviceType.Total:
                            item.总量在线状态ID = 801;
                            if (item.总量在离线状态时间 == null || item.总量在离线状态时间.Value < datatime)
                                item.总量在离线状态时间 = datatime;
                            break;
                    }
                }
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }

        public static void ProcessStatusByBiz()
        {
            try
            {
                using (PlatformContext pCtx = new PlatformContext())
                {
                    //var items = pCtx.RealDataMonitorMains.Where(t => t.数采在线状态ID == 802).ToList();
                    var items = pCtx.RealDataMonitorMains.ToList();
                    DateTime now = DateTime.Now;
                    foreach (var item in items)
                    {
                        if (item.实时数据时间 == null)
                        {
                            item.实时数据时间 = new DateTime(2017, 1, 1);
                        }

                        if (item.实时数据时间 >= now.AddHours(-1) && item.数采在线状态ID == 802)
                        {
                            item.数采在线状态ID = 801;
                        }
                        if (item.实时数据时间 < now.AddHours(-1) && item.数采在线状态ID == 801)
                        {
                            item.数采在线状态ID = 802;
                        }
                    }
                    pCtx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3081ForMonitor(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var type = CommonInformation.GetDeviceTypeByMn(mn);
                var items = pCtx.RealDataMonitorMains.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                    .Where(t => t.设备信息ID == letport.ID).ToList();
                foreach (var item in items)
                {
                    switch (type)
                    {
                        case DeviceType.Monitor:
                            item.数采市电状态ID = 701;
                            if (item.数采市电状态时间 < datatime)
                                item.数采市电状态时间 = datatime;
                            break;
                        case DeviceType.Total:
                            item.总量市电状态ID = 701;
                            if (item.总量市电状态时间 < datatime)
                                item.总量市电状态时间 = datatime;
                            break;
                    }
                }
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3081ForHistory(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var record = new 市电状态
                {
                    企业基本信息ID = letport.企业基本信息ID,
                    设备信息ID = letport.ID,
                    设备MN号 = mn,
                    执行日期 = datatime,
                    执行事项 = "市电停电"
                };
                pCtx.市电状态.Add(record);
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3082ForMonitor(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var type = CommonInformation.GetDeviceTypeByMn(mn);
                Log.Info(Enum.GetName(typeof(DeviceType), type));
                var items = pCtx.RealDataMonitorMains.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                    .Where(t => t.设备信息ID == letport.ID).ToList();
                foreach (var item in items)
                {
                    switch (type)
                    {
                        case DeviceType.Monitor:
                            item.数采市电状态ID = 702;
                            item.数采市电状态时间 = datatime;
                            break;
                        case DeviceType.Total:
                            item.总量市电状态ID = 702;
                            item.总量市电状态时间 = datatime;
                            break;
                    }
                    pCtx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3082ForHistory(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);

                var record = new 市电状态
                {
                    企业基本信息ID = letport.企业基本信息ID,
                    设备信息ID = letport.ID,
                    设备MN号 = mn,
                    执行日期 = datatime,
                    执行事项 = "市电供电"
                };
                pCtx.市电状态.Add(record);
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3071ForAlarm(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var port = CommonInformation.GetLetportByMn(mn);
                if (port == null) return;
                var enterprise = CommonInformation.GetPollutionSourceById(port.企业基本信息ID);
                if (enterprise == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);

                var item = pCtx.RealDataMonitorMains
                    .Where(t => t.企业基本信息ID == port.企业基本信息ID).FirstOrDefault(t => t.设备信息ID == port.ID);
                if (item == null) return;
                if (item.阀门状态 != null && item.阀门状态.Equals(MyConvertor.Int2Chinese(per))) return;

                StringBuilder sb = new StringBuilder();
                sb.Append(enterprise.企业名称)
                    .Append(datatime.ToString("F"))
                    .Append("阀门状态由")
                    .Append(item.阀门状态)
                    .Append("变为").Append("，请关注！");


                var contacts1 = CommonInformation.GetContacts(mn);

                if (contacts1 != null)
                {
                    foreach (var c1 in contacts1)
                    {
                        var record = new 报警记录
                        {
                            企业基本信息ID = port.企业基本信息ID,
                            设备信息ID = port.ID,
                            时间 = datatime,
                            内容 = sb.ToString(),
                            短信是否发送 = false,
                            是否需要声光报警 = "否",
                            短信接收人 = c1.联系人姓名,
                            短信手机号 = c1.联系人电话
                        };
                        pCtx.报警记录.Add(record);
                    }
                }
                pCtx.SaveChanges();
                var contacts2 = CommonInformation.GetEnterpriseContacts(mn);
                if (contacts2 != null)
                {
                    foreach (var c1 in contacts2)
                    {
                        var record = new 报警记录
                        {
                            企业基本信息ID = port.企业基本信息ID,
                            设备信息ID = port.ID,
                            时间 = datatime,
                            内容 = sb.ToString(),
                            短信是否发送 = false,
                            是否需要声光报警 = "否",
                            短信接收人 = c1.联系人一姓名,
                            短信手机号 = c1.联系人一电话
                        };
                        pCtx.报警记录.Add(record);
                        record = new 报警记录
                        {
                            企业基本信息ID = port.企业基本信息ID,
                            设备信息ID = port.ID,
                            时间 = datatime,
                            内容 = sb.ToString(),
                            短信是否发送 = false,
                            是否需要声光报警 = "否",
                            短信接收人 = c1.联系人二姓名,
                            短信手机号 = c1.联系人二电话
                        };
                        pCtx.报警记录.Add(record);
                    }
                }
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }

        public static void Process3071ForMonitor(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);
                var gate = Parser.GetStringByKey("Gate", content);

                var item = pCtx.RealDataMonitorMains
                    .Where(t => t.企业基本信息ID == letport.企业基本信息ID).FirstOrDefault(t => t.设备信息ID == letport.ID);
                if (item != null)
                {
                    item.阀门状态 = MyConvertor.Int2Chinese(per);
                    if (item.阀门状态时间 == null || item.阀门状态时间.Value < datatime)
                        item.阀门状态时间 = datatime;
                    item.门禁状态 = MyConvertor.English2Chinese(gate);
                    if (item.门禁状态时间 == null || item.门禁状态时间.Value < datatime)
                        item.门禁状态时间 = datatime;
                    pCtx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static bool Process3071ForResponse(PlatformContext pCtx, string content)
        {
            try
            {
                var qn = Parser.GetStringByKey("QN", content);
                if (string.IsNullOrEmpty(qn)) return false;
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return false;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return false;
                var records = pCtx.反控阀门.Where(t => t.QN.Equals(qn)).Where(t => t.企业基本信息ID == letport.企业基本信息ID).Where(t => t.设备信息ID == letport.ID).ToList();
                if (records.Count < 1) return false;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);
                foreach (var record in records)
                {
                    record.阀门状态 = MyConvertor.Int2Chinese(per);
                    record.时间 = datatime;
                }
                pCtx.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return false;
        }
        public static void Process3071ForHistory(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);
                var gate = Parser.GetStringByKey("Gate", content);
                var history = new StateMonitorHistoryRecord
                {
                    企业基本信息ID = letport.企业基本信息ID,
                    设备信息ID = letport.ID,
                    阀门状态 = MyConvertor.Int2Chinese(per),
                    阀门状态时间 = datatime,
                    门禁状态 = MyConvertor.English2Chinese(gate),
                    门禁状态时间 = datatime
                };
                pCtx.StateMonitorHistoryRecords.Add(history);
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3071ForState(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);
                var gate = Parser.GetStringByKey("Gate", content);
                var state =
                    pCtx.StateMonitors.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                        .FirstOrDefault(t => t.设备信息ID == letport.ID);
                if (state == null)
                {
                    state = new StateMonitor
                    {
                        企业基本信息ID = letport.企业基本信息ID,
                        设备信息ID = letport.ID
                    };
                    pCtx.StateMonitors.Add(state);
                }
                state.阀门状态 = MyConvertor.Int2Chinese(per);

                if (state.阀门状态时间 == null || state.阀门状态时间.Value < datatime)
                    state.阀门状态时间 = datatime;
                state.门禁状态 = MyConvertor.English2Chinese(gate);
                if (state.门禁状态时间 == null || state.门禁状态时间.Value < datatime)
                    state.门禁状态时间 = datatime;

                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }

        public static void Process3097ForMonitor(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Gate", content);
                if (string.IsNullOrEmpty(per)) return;
                var item = pCtx.RealDataMonitorMains
                    .Where(t => t.企业基本信息ID == letport.企业基本信息ID).FirstOrDefault(t => t.设备信息ID == letport.ID);
                if (item != null)
                {
                    item.门禁状态 = MyConvertor.English2Chinese(per);
                    if (item.门禁状态时间 < datatime)
                        item.门禁状态时间 = datatime;

                    pCtx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static bool Process3097ForResponse(PlatformContext pCtx, string content)
        {
            try
            {
                var qn = Parser.GetStringByKey("QN", content);
                if (string.IsNullOrEmpty(qn)) return false;
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return false;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return false;
                //var records = pCtx.反控门禁.Where(t => t.QN.Equals(qn)).Where(t => t.企业基本信息ID == letport.企业基本信息ID).Where(t => t.设备信息ID == letport.ID).ToList();
                //if (records.Count < 1) return false;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Gate", content);
                if (per == null) return false;
                var cardNo = Parser.GetStringByKey("CardNo", content);
                var cardType = Parser.GetStringByKey("CardType", content);
                var record = new 反控门禁();
                record.QN = qn;
                record.企业基本信息ID = letport.企业基本信息ID;
                record.设备信息ID = letport.ID;
                record.门禁状态 = MyConvertor.English2Chinese(per);
                record.时间 = datatime;
                record.卡号 = cardNo.ToUpper();
                record.卡类型 = MyConvertor.TypeEnglish2Chinese(cardType);
                record.执行事项ID = 1202;
                record.执行结果标志ID = 603;
                pCtx.反控门禁.Add(record);
                pCtx.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return false;
        }
        public static void Process3097ForHistory(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Gate", content);
                if (per == null) return;
                var history = new StateMonitorHistoryRecord
                {
                    企业基本信息ID = letport.企业基本信息ID,
                    设备信息ID = letport.ID,
                    门禁状态 = MyConvertor.English2Chinese(per),
                    门禁状态时间 = datatime
                };
                pCtx.StateMonitorHistoryRecords.Add(history);
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process3097ForState(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByDataTimeThenQnThenNow(content);
                var per = Parser.GetStringByKey("Per", content);
                var state =
                    pCtx.StateMonitors.Where(t => t.企业基本信息ID == letport.企业基本信息ID)
                        .FirstOrDefault(t => t.设备信息ID == letport.ID);
                if (state == null)
                {
                    state = new StateMonitor
                    {
                        企业基本信息ID = letport.企业基本信息ID,
                        设备信息ID = letport.ID,

                    };
                    pCtx.StateMonitors.Add(state);
                }
                state.阀门状态 = MyConvertor.Int2Chinese(per);
                if (state.阀门状态时间 < datatime)
                    state.阀门状态时间 = datatime;
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }

        public static void Process4012ForState(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByKey("DataTime", content);
                if (datatime == null) return;

                var state =
                    pCtx.BottleStateMonitors
                        .FirstOrDefault(t => t.工控机组名ID == letport.工控机组名ID);
                if (state == null)
                {
                    state = new BottleStateMonitor
                    {
                        工控机组名ID = letport.工控机组名ID,
                        状态时间 = datatime.Value
                    };
                    pCtx.BottleStateMonitors.Add(state);
                }
                state.状态时间 = datatime.Value;
                state.瓶号1 = Parser.GetFloatByKey("VaseNo1-Quantity", content) + "";
                state.瓶号2 = Parser.GetFloatByKey("VaseNo2-Quantity", content) + "";
                state.瓶号3 = Parser.GetFloatByKey("VaseNo4-Quantity", content) + "";
                state.瓶号4 = Parser.GetFloatByKey("VaseNo4-Quantity", content) + "";
                state.瓶号5 = Parser.GetFloatByKey("VaseNo5-Quantity", content) + "";
                state.瓶号6 = Parser.GetFloatByKey("VaseNo6-Quantity", content) + "";
                state.瓶号7 = Parser.GetFloatByKey("VaseNo7-Quantity", content) + "";
                state.瓶号8 = Parser.GetFloatByKey("VaseNo8-Quantity", content) + "";
                state.瓶号9 = Parser.GetFloatByKey("VaseNo9-Quantity", content) + "";
                state.瓶号10 = Parser.GetFloatByKey("VaseNo10-Quantity", content) + "";
                state.瓶号11 = Parser.GetFloatByKey("VaseNo11-Quantity", content) + "";
                state.瓶号12 = Parser.GetFloatByKey("VaseNo12-Quantity", content) + "";
                state.瓶号13 = Parser.GetFloatByKey("VaseNo13-Quantity", content) + "";
                state.瓶号14 = Parser.GetFloatByKey("VaseNo14-Quantity", content) + "";
                state.瓶号15 = Parser.GetFloatByKey("VaseNo15-Quantity", content) + "";
                state.瓶号16 = Parser.GetFloatByKey("VaseNo16-Quantity", content) + "";
                state.瓶号17 = Parser.GetFloatByKey("VaseNo17-Quantity", content) + "";
                state.瓶号18 = Parser.GetFloatByKey("VaseNo18-Quantity", content) + "";
                state.瓶号19 = Parser.GetFloatByKey("VaseNo19-Quantity", content) + "";
                state.瓶号20 = Parser.GetFloatByKey("VaseNo20-Quantity", content) + "";
                state.瓶号21 = Parser.GetFloatByKey("VaseNo21-Quantity", content) + "";
                state.瓶号22 = Parser.GetFloatByKey("VaseNo22-Quantity", content) + "";
                state.瓶号23 = Parser.GetFloatByKey("VaseNo23-Quantity", content) + "";
                state.瓶号24 = Parser.GetFloatByKey("VaseNo24-Quantity", content) + "";
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public static void Process4012ForHistory(PlatformContext pCtx, string content)
        {
            try
            {
                var mn = Parser.GetStringByKey("MN", content);
                if (string.IsNullOrEmpty(mn)) return;
                var letport = CommonInformation.GetLetportByMn(mn);
                if (letport == null) return;
                var datatime = Parser.GetDateTimeByKey("DataTime", content);
                if (datatime == null) return;

                var state = new BottleStateMonitorHistoryRecord
                {
                    工控机组名ID = letport.工控机组名ID,
                    状态时间 = datatime.Value
                };
                pCtx.BottleStateMonitorHistoryRecords.Add(state);

                state.瓶号1 = Parser.GetFloatByKey("VaseNo1-Quantity", content) + "";
                state.瓶号2 = Parser.GetFloatByKey("VaseNo2-Quantity", content) + "";
                state.瓶号3 = Parser.GetFloatByKey("VaseNo4-Quantity", content) + "";
                state.瓶号4 = Parser.GetFloatByKey("VaseNo4-Quantity", content) + "";
                state.瓶号5 = Parser.GetFloatByKey("VaseNo5-Quantity", content) + "";
                state.瓶号6 = Parser.GetFloatByKey("VaseNo6-Quantity", content) + "";
                state.瓶号7 = Parser.GetFloatByKey("VaseNo7-Quantity", content) + "";
                state.瓶号8 = Parser.GetFloatByKey("VaseNo8-Quantity", content) + "";
                state.瓶号9 = Parser.GetFloatByKey("VaseNo9-Quantity", content) + "";
                state.瓶号10 = Parser.GetFloatByKey("VaseNo10-Quantity", content) + "";
                state.瓶号11 = Parser.GetFloatByKey("VaseNo11-Quantity", content) + "";
                state.瓶号12 = Parser.GetFloatByKey("VaseNo12-Quantity", content) + "";
                state.瓶号13 = Parser.GetFloatByKey("VaseNo13-Quantity", content) + "";
                state.瓶号14 = Parser.GetFloatByKey("VaseNo14-Quantity", content) + "";
                state.瓶号15 = Parser.GetFloatByKey("VaseNo15-Quantity", content) + "";
                state.瓶号16 = Parser.GetFloatByKey("VaseNo16-Quantity", content) + "";
                state.瓶号17 = Parser.GetFloatByKey("VaseNo17-Quantity", content) + "";
                state.瓶号18 = Parser.GetFloatByKey("VaseNo18-Quantity", content) + "";
                state.瓶号19 = Parser.GetFloatByKey("VaseNo19-Quantity", content) + "";
                state.瓶号20 = Parser.GetFloatByKey("VaseNo20-Quantity", content) + "";
                state.瓶号21 = Parser.GetFloatByKey("VaseNo21-Quantity", content) + "";
                state.瓶号22 = Parser.GetFloatByKey("VaseNo22-Quantity", content) + "";
                state.瓶号23 = Parser.GetFloatByKey("VaseNo23-Quantity", content) + "";
                state.瓶号24 = Parser.GetFloatByKey("VaseNo24-Quantity", content) + "";
                pCtx.SaveChanges();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
    }
}
